/*
 * Child.java
 *
 * Creada el 30/01/2012, 04:20:11 PM
 *
 * Clase Java desarrollada por Edgar Ramos para 7i Software Factory el día 30/01/2012
 *
 * Para informacion sobre el uso de esta clase, asi como bugs, actualizaciones, o mejoras enviar un mail a
 * eramos@7i.com.mx
 *
 * Desarrollado por la célula de desarrollo de Zacatecas
 *
 */
package com.grupoquark.cic.model.person;

import com.grupoquark.cic.model.enums.House;
import com.grupoquark.cic.model.period.Period;
import com.grupoquark.cic.model.register.PointsRegister;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Parent;

/**
 * @author Edgar Ramos
 * @version 1.0
 * @author-mail eramos@7i.com.mx
 * @date 30/01/2012
 */
@Entity
@Table(name = "children")
public class Child extends Person
{
    private House house;
    @Column(name = "points_history")
    @OneToMany(cascade = CascadeType.PERSIST)
    private List<PointsRegister> pointsHistory;
    @Column(name = "medical_indications")
    private String medicalIndications;
    @ManyToOne(fetch = FetchType.EAGER)
    Parent parent;
    @Column(name = "periods_registered")
    @ManyToMany
    private List<Period> registeredPeriods;

    protected Child()
    {
    }

    public Child(String name, String firstSurname, String secondSurname)
    {
        super(name, firstSurname, secondSurname);
    }

    public Child(String name, String firstSurname)
    {
        super(name, firstSurname);
    }

    public House getHouse()
    {
        return house;
    }

    public void setHouse(House house)
    {
        this.house = house;
    }

    public String getMedicalIndications()
    {
        return medicalIndications;
    }

    public void setMedicalIndications(String medicalIndications)
    {
        this.medicalIndications = medicalIndications;
    }

    public Parent getParent()
    {
        return parent;
    }

    public void setParent(Parent parent)
    {
        this.parent = parent;
    }

    public List<PointsRegister> getPointsHistory()
    {
        return pointsHistory;
    }

    public void setPointsHistory(List<PointsRegister> pointsHistory)
    {
        this.pointsHistory = pointsHistory;
    }

    public List<Period> getRegisteredPeriods()
    {
        return registeredPeriods;
    }

    public void setRegisteredPeriods(List<Period> registeredPeriods)
    {
        this.registeredPeriods = registeredPeriods;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final Child other = (Child) obj;
        if (this.house != other.house)
        {
            return false;
        }
        if (this.pointsHistory != other.pointsHistory && (this.pointsHistory == null || !this.pointsHistory.equals(other.pointsHistory)))
        {
            return false;
        }
        if ((this.medicalIndications == null) ? (other.medicalIndications != null) : !this.medicalIndications.equals(other.medicalIndications))
        {
            return false;
        }
        if (this.parent != other.parent && (this.parent == null || !this.parent.equals(other.parent)))
        {
            return false;
        }
        if (this.registeredPeriods != other.registeredPeriods && (this.registeredPeriods == null || !this.registeredPeriods.equals(other.registeredPeriods)))
        {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 83 * hash + (this.house != null ? this.house.hashCode() : 0);
        hash = 83 * hash + (this.pointsHistory != null ? this.pointsHistory.hashCode() : 0);
        hash = 83 * hash + (this.medicalIndications != null ? this.medicalIndications.hashCode() : 0);
        hash = 83 * hash + (this.parent != null ? this.parent.hashCode() : 0);
        hash = 83 * hash + (this.registeredPeriods != null ? this.registeredPeriods.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString()
    {
        return "Child{" + "house=" + house + ", pointsHistory=" + pointsHistory + ", medicalIndications=" + medicalIndications + ", parent=" + parent + ", periodsRegistered=" + registeredPeriods + '}';
    }
}
